<template>
    <div class="received_page">
        <div class="received_congra" v-if="is_ok=='ok'">
            <img :src="success_img">
            <p>
                礼物领取成功，坐等收货吧！
            </p>
        </div>
        <div class="received_thanks" v-if="is_ok=='ok'">
            <div class="mini_btn" @click="goToMarketList();">
                我要回礼
            </div>
        </div>
        <div class="received_congra" v-if="is_ok=='sorry'">
            <img :src="sorry_img" style="width: 9rem">
            <p>
                哎呀呀，来晚一步，礼物被领完啦~
            </p>
        </div>
        <div class="received_thanks" v-if="is_ok=='sorry'">
            <div class="mini_btn" @click="goToMarket();">
                查看商品
            </div>
        </div>
        <div class="received_attention">
            <img :src=" 'http://' + current_host + wx_img_url + mp_info.wx_qrcode_url">
            <p>
                长按识别二维码，关注有福商城
            </p>
        </div>
    </div>
</template>

<script>
import api from '@/api/api'
export default {
    name: 'giftReceived',
    data() {
        return {
            order_data: {},
            is_ok: this.$route.query.is_ok,
            success_img: require('assets/images/icon_tick.png'),
            sorry_img: require('assets/images/kong.png'),
            default_qrcode: require('assets/images/qrcode.jpg'),
        }
    },
    methods: {
        postStepChange: function (val) {
            var _self = this;
            _self.now_step += 1;
            _self.step_list[val + 1].is_active = true;
        },
        goToMarket: function () {
            let market_url = this.current_host + '/mp/market/detail/' + this.order_data.resource_id;
            window.location.replace(market_url);
        },

        goToMarketList: function () {
            let market_url = this.current_host + '/mp/home';
            alert(market_url);
            window.location.replace(market_url);
        },
        getOrderInfo: function () {
            let order_params = {
                functioncode: 'give_gifts_info',
                gift_id: this.$route.params.gift_id
            }
            api.get(order_params).then((res) => {
                if (res.data.returncode == '000000') {
                    this.order_data = res.data.record;
                }
            });
        },
    },
    mounted: function () {
        this.$nextTick(function () {
            this.getOrderInfo();
        });
    }
}
</script>

<style scoped>
body {
    background: #f2f2f2;
    margin: 0;
}
</style>
